<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>提现账号管理</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body {
            width: 100%;
            background-color: #f7f7f7;
            font-size: 0.28rem;
            height: auto;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: PingFangSC-Regular, sans-serif;
            color: #333333;
            box-sizing: border-box;
        }

        #wrapper {
            width: 6.9rem;
            margin-left: calc((100% - 6.9rem) / 2);
        }

        #wrappernew {
            width: 6.9rem;
            margin-left: calc((100% - 6.9rem) / 2);
        }

        .item {
            width: 100%;
            height: 1.6rem;
            background: #FFFFFF;
            border-radius: 0.1rem;
            overflow: hidden;
        }

        .item-scroller {
            width: 120%;
            position: absolute;
            background: linear-gradient(to right, #dbaf6c, #e5ca93);
            background: -webkit-linear-gradient(to right, #dbaf6c, #e5ca93);
            border-radius: 0.1rem;
        }

        .item-scroller>img {
            width: 0.15rem;
            height: 0.3rem;
            position: absolute;
            top: 0.7rem;
            right: 2.2rem;
        }

        .item-scroller .txt {
            height: 1.6rem;
            margin-left: 0.6rem;
            font-size: 0.32rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            justify-content: center;
            width: 4rem;
            color: rgba(255, 255, 255, 0.8);
        }

        .item-scroller .txt span:last-of-type {
            font-size: 0.26rem;
        }

        .itemnew {
            width: 100%;
            height: 1.2rem;
            background: #FFFFFF;
            border-radius: 0.1rem;
            overflow: hidden;
        }

        .item-scrollernew {
            width: 120%;
            position: absolute;
            background: #ffffff;
            border-radius: 0.1rem;

        }

        .item-scrollernew>img {
            width: 0.15rem;
            height: 0.3rem;
            position: absolute;
            top: 0.7rem;
            right: 2.2rem;
        }

        .item-scrollernew .txt {
            height: 1.2rem;
            margin-left: 0.2rem;
            font-size: 0.32rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            justify-content: center;
            width: 4rem;
            color: rgba(255, 255, 255, 0.8);
        }

        .item-scrollernew .txt span:last-of-type {
            font-size: 0.26rem;
            color: #272727;
        }

        .adressTtitle {
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .showBankDetial {
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .del {
            width: 13%;
            height: 1.6rem;
            position: absolute;
            right: 0;
            top: 0;
            color: #fff;
            text-align: center;
            line-height: 1.6rem;
            z-index: 9999;
        }

        .delnew {
            width: 13%;
            height: 1.2rem;
            position: absolute;
            right: 0;
            top: 0;
            color: #fff;
            text-align: center;
            line-height: 1.2rem;
            z-index: 9999;
        }

        .del .shanchu {
            width: 100%;
            height: 1.6rem;
            text-align: center;
            background: red;
            float: left;
            line-height: 1.6rem;
        }

        .delnew .shanchu {
            width: 100%;
            height: 1.2rem;
            text-align: center;
            background: red;
            float: left;
            line-height: 1.2rem;
        }

        li {
            border-radius: 0.1rem;
            margin-bottom: 0.3rem;
        }

        #gopageBank {
            position: absolute;
            left: 65%;
            top: 45%;
        }

        .addCardButton {
            border: 1px solid #e2e2e2;
            height: 1.42rem;
            border-radius: 0.1rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 0.26rem;
        }

        .addAdressButton {
            border: 1px solid #e2e2e2;
            height: 1.42rem;
            border-radius: 0.1rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 0.26rem;
        }

        .headerTitle {
            width: 100%;
            height: auto;
            position: sticky;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-around;
            background-color: #fff;
        }

        .headerTitle p {
            width: auto;
            height: 0.79rem;
            border-bottom: 0.05rem solid #ffffff;
            line-height: 0.79rem;
            color: #8A8A8A;
            font-size: 0.3rem;
        }

        .headerTitle .checkedP {
            border-bottom-color: #fff203;
            color: #272727;
        }

        .headerTitle p:last-of-type {
            margin-left: 0.1rem;
        }

        #wrappernew {
            padding-bottom: 0.2rem;
            -webkit-overflow-scrolling: touch;
        }
    </style>
</head>

<body>
    <div class="headerTitle">
        <p class="checkedP" data-value="bankCardList">
            银行卡
        </p>
        <p data-value="outAdressList">
            提币地址
        </p>
    </div>
    <div class="bankCardList hideBox">
        <div id="wrapper" style="margin-top:0.3rem;">
            <ul id="scroller">
            </ul>
        </div>
        <div style="width: 6.9rem;margin-left:calc((100% - 6.9rem)/2)">
            <div class="addCardButton">
                <span style="font-size: 0.6rem">
                    ＋
                </span>
                <span>
                    添加提现账号
                </span>
            </div>
            <p style="margin-top:0.36rem;font-size:0.24rem;color:#949494;">
                <span style="color: #262626;">提示&nbsp;</span> 3张银行卡
            </p>
        </div>
    </div>
    <div class="outAdressList hideBox" style="display: none;">
        <div id="wrappernew" style="margin-top:0.3rem;">
            <ul id="scrollernew">
                <!-- <li class="itemnew" data-id='12' ontouchend="touchend()" ontouchmove="touchend()"
                    ontouchstart="touchstart()">
                    <div class="item-scrollernew">
                        <div class="txt">
                            <p class="adressTtitle"><img src="../../image/icondizhix.png"
                                    style="width:0.28rem;margin-right:0.15rem;"><span>USDT(OMNI)人人矿场</span>
                            </p>
                            <span
                                style="margin-left: 0.43rem;color:#B2B2B2;">19fhfuha12uhfashfoahgagjagou1u4gu1gk4</span>
                        </div>
                        <div class="delnew">
                            <div class="shanchu" data-name='1'>删除</div>
                        </div>
                    </div>
                </li> -->
            </ul>
        </div>
        <div style="width: 6.9rem;margin-left:calc((100% - 6.9rem)/2);padding-top: 0.2rem;">
            <div class="addAdressButton">
                <span style="font-size: 0.6rem">
                    ＋
                </span>
                <span>
                    添加提币地址
                </span>
            </div>
        </div>
    </div>
    <script src="../../script/autosize.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/jquery_three_two_one.js"></script>
    <script src="../../script/jrollmin.js"></script>
    <script src="../../script/app.js"></script>
    <script>
        function getTimeNow() {
            var now = new Date();
            return now.getTime();
        }

        function touchend() {
            clearInterval(time); //如果按下时间不到1000毫秒便弹起，
        }
        function touchstart() {
            timeStart = getTimeNow(); //获取鼠标按下时的时间
            time = setInterval(function () {
                timeEnd = getTimeNow(); //也就是每100毫秒获取一次时间
                if (timeEnd - timeStart > 700) //如果此时检测到的时间与第一次获取的时间差有1000毫秒
                {
                    clearInterval(time); //便不再继续重复此函数 （clearInterval取消周期性执行）
                }
            }, 100);
        }
    </script>
    <script>
        apiready = function () {
            var app = new APP();
            var account = app.getAccount();
            var obj = {};
            var isOversea = api.pageParam.isOversea;
            var isAddBank = true;
            function jroll() {
                // 创建外层jroll实例
                var jroll = new JRoll("#wrapper", {
                    scrollBarY: false
                });
                var items = document.querySelectorAll(".item");
                var current = null;
                //保存当前滑开的item
                for (var i = 0; i < items.length; i++) {
                    // 每行创建jroll实例
                    var j = new JRoll(items[i], {
                        scrollX: true,
                        bounce: false
                    });
                    j.on("scrollStart", function () {
                        if (current && current !== this) {
                            current.scrollTo(0, 0, 100);
                            current = null;
                        }
                    });
                    j.on("scroll", function (e) {
                        if (this.x === 0 && !current) {
                            this.call(jroll, e);
                        } else {
                            current = this;
                        }
                    });
                    j.on("scrollEnd", function () {
                        if (this.x > -50) {
                            this.scrollTo(0, 0, 100);
                            current = null;
                        } else {
                            this.scrollTo(this.maxScrollX, 0, 100);
                        }
                    })
                };
            }
            function jrollnew() {
                // 创建外层jroll实例
                var jroll = new JRoll("#wrappernew", {
                    scrollBarY: true,
                    scroll: true
                });
                var items = document.querySelectorAll(".itemnew");
                var current = null;
                //保存当前滑开的item
                for (var i = 0; i < items.length; i++) {
                    // 每行创建jroll实例
                    var j = new JRoll(items[i], {
                        scrollX: true,
                        bounce: false
                    });
                    j.on("scrollStart", function () {
                        if (current && current !== this) {
                            current.scrollTo(0, 0, 100);
                            current = null;
                        }
                    });
                    j.on("scroll", function (e) {
                        if (this.x === 0 && !current) {
                            this.call(jroll, e);
                        } else {
                            current = this;
                        }
                    });
                    j.on("scrollEnd", function () {
                        if (this.x > -50) {
                            this.scrollTo(0, 0, 100);
                            current = null;
                        } else {
                            this.scrollTo(this.maxScrollX, 0, 100);
                        }
                    })
                };
            }

            $(".addCardButton").on("click", function () {
                if (isAddBank == false) {
                    app.toast("最多绑定三张银行卡");
                    return
                }
                app.trigger("thisCountry")
            });

            var bankCardID = "";
            var userIDName = "";
            var bankCardList = [];
            var isAddCard = true;
            //获取银行卡列表
            function loadPageT() {
                var account = app.getAccount();
                app.ajaxPro({
                    url: "member/show-bank",
                    values: {
                        token: account.token
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        userIDName = ret.data.real_info.name;
                        if (ret.data.list.length >= 3) {
                            isAddBank = false;
                        } else {
                            isAddBank = true;
                        }
                        ret.data.list.map(function (item) {
                            item.title = item.bank_name ? item.bank_name : item.name;
                            item.subTitle = item.username + "&nbsp;&nbsp;|&nbsp;&nbsp;尾号:" + item.bank_card_num.slice(-4);
                            item.imgPath = item.small_img == null ? account.avatar : item.small_img;
                            item.icon = "widget://image/rightwrix.png";
                        });
                        bankCardList = JSON.parse(JSON.stringify(ret.data.list));
                        if (ret.data.list.length > 0) {
                            var html = ''
                            for (var i = 0; i < ret.data.list.length; i++) {
                                html += '<li class="item" data-id=' + i + '  ontouchend="touchend()" ontouchmove="touchend()" ontouchstart="touchstart()">'
                                html += '  <div class="item-scroller">'
                                html += '    <div class="txt">'
                                html += '       <span>' + ret.data.list[i].title + '</span>'
                                html += '       <span>' + ret.data.list[i].subTitle + '</span>'
                                html += '    </div>'
                                html += '    <img src="../../image/rightwrix.png">'
                                html += '    <div class="del">'
                                html += '      <div class="shanchu" data-name=' + i + '>删除</div>'
                                html += '    </div>'
                                html += '  </div>'
                                html += '</li>'
                            }
                            $('#scroller').append(html)
                            jroll(); // 调用jroll
                        }
                        $("#scroller").on("click", "li", function () {
                            var thisContant = $(this).attr("data-id");
                            var pageValue = {
                                name: "addcard",
                                subpage: "mine/addcard",
                                title: "编辑银行卡信息",
                                param: {
                                    pageName: "addcard",
                                    allowEdit: true,
                                    idname: bankCardList[thisContant].username,
                                    bank: bankCardList[thisContant].bank_name,
                                    bankard: bankCardList[thisContant].bank_card_num,
                                    khh: bankCardList[thisContant].card_name,
                                    bankID: bankCardList[thisContant].bank_id,
                                    userBankID: bankCardList[thisContant].id,
                                    isOversea: isOversea.type
                                },
                            }
                            app.setNavBarAttr(pageValue);
                        })
                        $("#scroller").on("click", ".shanchu", function (e) {
                            e.stopPropagation();
                            var thisTD = $(this).attr("data-name");
                            bankCardID = bankCardList[thisTD].id;
                            var param = {
                                dtype: "dialog1",
                                data: {
                                    text: "亲,你确定要删除尾号为" + bankCardList[thisTD].bank_card_num.slice(-4) + "的银行卡吗？",
                                    btns: [{
                                        name: "再想想",
                                        event: "YesBack"
                                    },
                                    {
                                        name: "确定删除",
                                        event: "canleCard"
                                    }
                                    ]
                                }
                            };
                            app.dialog(param);
                            return
                        })
                    }
                })
            };
            loadPageT();
            //获取地址列表
            function getAdressList() {
                var account = app.getAccount();
                app.ajaxPro({
                    url: "member/get-tb-address",
                    values: {
                        token: account.token
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        var newarr = ret.data.lists;
                        if (newarr.length > 0) {
                            var teplte = '';
                            for (var i = 0; i < newarr.length; i++) {
                                teplte += '<li class="itemnew" data-id=' + newarr[i].id + 'ontouchend="touchend()" ontouchmove="touchend()"ontouchstart="touchstart()"><div class="item-scrollernew"><div class="txt"><p class="adressTtitle"><img src="../../image/icondizhix.png"style="width:0.28rem;margin-right:0.15rem;"><span>' + newarr[i].remark + '</span></p><span style="margin-left: 0.43rem;color:#B2B2B2;">' + newarr[i].wallet_address + '</span></div><div class="delnew"><div class="shanchu" data-name=' + newarr[i].id + '>删除</div></div></div></li>'
                            }
                            $("#scrollernew").append(teplte);
                            if (newarr.length > 6) {
                                $("#wrappernew").css({
                                    height: app.H * 0.7,
                                    overflowY: "scroll !important"
                                })
                            }
                            jrollnew();
                        }
                    }
                })
            }
            function debounce(fn, delay) {
                var timer;
                return function () {
                    var context = this;
                    var args = arguments;
                    clearTimeout(timer);
                    timer = setTimeout(function () {
                        fn.apply(context, args)
                    }, delay)
                }
            };
            $(".headerTitle p").click(debounce(function () {
                var pageBox = $(this).attr("data-value");
                $(".hideBox").hide();
                $(".headerTitle p").removeClass("checkedP");
                $(this).addClass("checkedP");
                $("." + pageBox).fadeIn();
                $('#scroller,#scrollernew').empty();
                if (pageBox == "bankCardList") {
                    loadPageT();
                } else {
                    getAdressList();
                }
            }, 500))
            $(".addAdressButton").click(function () {
                var pageValue = {
                    name: "adress_add",
                    subpage: "salescommission/adress_add",
                    title: "添加提币地址",
                    allowEdit: true,
                    param: {
                        pageName: "adress_add",
                        allowEdit: true
                    },
                }
                app.setNavBarAttr(pageValue);
            })
            app.listen("thisCountry", function () {
                var pageValue = {
                    name: "addcard",
                    subpage: "mine/addcard",
                    title: "添加银行卡",
                    param: {
                        pageName: "addcard",
                        allowEdit: true,
                        idname: userIDName,
                        isOversea: isOversea.type
                    },
                }
                app.setNavBarAttr(pageValue);
            })
            app.listen("canleCard", function () {
                app.ajax({
                    param: {
                        method: "post",
                        url: app.ajaxUrl + "member/del-bank",
                        data: {
                            values: {
                                token: account.token,
                                bank_id: bankCardID
                            }
                        },
                        callback: function (ret, err) {
                            if (ret.code == 200) {
                                app.toast("删除成功");
                                $('#scroller').empty();
                                loadPageT();
                            } else {
                                app.toast(ret.message);
                            }
                        }
                    }
                })
            });
            var deletId = "";//删除地址ID
            $("#scrollernew").on("click", "li .shanchu", function () {
                deletId = $(this).attr("data-name");
                var param = {
                    dtype: "dialog53",
                    data: {
                        title: '提示',
                        text: "确认删除该提币地址？",
                        cancel: 'cancel',
                        confirm: 'confirmDelet',
                        cancentxt: '取消',
                        confirmtxt: '确定',
                        stopPropagation: true,//阻止点击body冒泡
                    }
                };
                //提示公共弹窗
                app.dialog(param);
            })
            app.listen("confirmDelet", function () {
                if (!deletId) return
                app.ajaxPro({
                    url: "member/del-tb-address",
                    values: {
                        token: account.token,
                        id: deletId
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        app.toast("删除成功");
                        deletId = "";
                        $('#scrollernew').empty();
                        getAdressList();
                    }
                })
            })
            app.listen("addAdrssSu", function () {
                $('#scrollernew').empty();
                getAdressList();
            })
            app.listen("add_card_success", function () {
                $('#scroller').empty();
                loadPageT();
            });
            app.headerMap();
        }
    </script>
</body>

</html>